package com.example.wujinapi.test;

import java.util.concurrent.TimeUnit;

class Phone{
    public static synchronized void sendEmail(){
        try {TimeUnit.SECONDS.sleep(3);} catch (Exception e) {e.printStackTrace();}
        System.out.println("----发送邮件");

    }
    public synchronized void sendSMS(){
        System.out.println("----发送短信");
    }
}

public class test {
    public static void main(String[] args) {
        Phone phone=new Phone();
        Phone phone2=new Phone();

        new Thread(()->{
            phone.sendEmail();
        },"A线程").start();



        new Thread(()->{
            phone.sendSMS();
        },"B线程").start();


        //第一种方式
        Thread T1=new Thread(()->{
            System.out.println("我是T1线程");
        },"T1");
        T1.start();

        //第二种方式
        new Thread(()->{
            System.out.println("我是T1线程");
        },"T1县城").start();




    }
}



